package com.xx.job.controller.system;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xx.job.common.PageResult;
import com.xx.job.common.Result;
import com.xx.job.controller.dto.PageDTO;
import com.xx.job.entity.system.SysTables;
import com.xx.job.service.system.SysTablesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;
import com.xx.job.controller.base.BaseController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liangcy
 * @since 2021-01-14
 */
@RestController
@RequestMapping("/api/v1")
public class SysTablesController extends BaseController {

    @Autowired
    private SysTablesService sysTablesService;

    @RequestMapping("/sys/tables/page")
    public Result tableslist(PageDTO pageDTO, SysTables sysTables){
        IPage<SysTables> sysOperaLogIPage;
        sysOperaLogIPage = sysTablesService.selectPage(pageDTO, sysTables);
        return Result.success(new PageResult(sysOperaLogIPage));
    }

    @PostMapping("/tables")
    public Result addTables(@RequestBody SysTables sysTables){
        return Result.success(sysTablesService.add(sysTables));
    }

    @DeleteMapping("/tables/{id}")
    public Result deleteTables(@PathVariable Long id){
        return Result.success(sysTablesService.delete(id));
    }

    @PutMapping("/tables")
    public Result updateTables(@RequestBody SysTables sysTables){
        return Result.success(sysTablesService.update(sysTables));
    }

    @GetMapping("/tables/{id}")
    public Result selectTables(@PathVariable Long id){
        return Result.success(sysTablesService.select(id));
    }
    
}

